<style>
  .is_count{
    font-size: 12px;
    height: 32%;
  }
  .is_count_div{
    height: 150px;
  }
</style>
<template>
  <div class="dashboard-editor-container">
    <panel-group @handleSetLineChartData="handleSetLineChartData" />
  </div>
</template>

<script>
import GithubCorner from '@/components/GithubCorner'
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
import RaddarChart from './components/RaddarChart'
import PieChart from './components/PieChart'
import BarChart from './components/BarChart'
import TransactionTable from './components/TransactionTable'
import TodoList from './components/TodoList'
import BoxCard from './components/BoxCard'
const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}
export default {
  name: 'DashboardAdmin',
  components: {
    GithubCorner,
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart,
    TransactionTable,
    TodoList,
    BoxCard
  },
  data() {
    return {
      dateTime: '',
      message: [],
      lineChartData: {
        startTime: [],
        endTime: [],
        time: [],
        exchang_numData: [],
        sale_after_numData: [],
        trading_amountData: [],
        user_numData: [],
        xAxis_data: []
      },
      obj: {
        time: [],
        exchang_numData: [],
        sale_after_numData: [],
        trading_amountData: [],
        user_numData: [],
        xAxis_data: []
      },
      count: []
    }
  },
  created: function() {
    // this.get_merchant_data_statistics_msg()
    // info(store.getters.token).then(res => {
    //   this.message = res.data.data
    // })
  },
  methods: {
    handleFilter() {
    },
    timestampToTime(timestamp) {
      var date = new Date(timestamp)
      var Y = date.getFullYear() + '-'
      var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
      var D = date.getDate()
      return Y + M + D
    },
    // get_merchant_data_statistics_msg() {
    //   const that = this
    //   let time = ''
    //   let end_time = ''
    //   const day = 60 * 60 * 24
    //   if (this.dateTime.length > 0) {
    //     end_time = this.dateTime[1].toString().substring(0, 10)
    //     time = this.dateTime[0].toString().substring(0, 10)
    //     const utc = end_time - time
    //     const dif = utc / day + 1
    //     if (dif > 14) {
    //       this.$message({
    //         showClose: true,
    //         message: '查询时间不可超过15天，当前查询日期：' + this.timestampToTime(this.dateTime[0]) + '至' + this.timestampToTime(this.dateTime[1]) + '，总天数：' + dif,
    //         type: 'warning'
    //       })
    //       return false
    //     }
    //   } else {
    //     end_time = (new Date().getTime()).toString().substring(0, 10)
    //     time = end_time - day * 6
    //   }
    //   get_merchant_data_statistics_msg(store.getters.token, {
    //     token: store.getters.token,
    //     time: time,
    //     end_time: end_time
    //   }).then(res => {
    //     that.lineChartData.exchang_numData = []
    //     that.lineChartData.sale_after_numData = []
    //     that.lineChartData.trading_amountData = []
    //     that.lineChartData.user_numData = []
    //     that.lineChartData.xAxis_data = []
    //     res.data.data.forEach(function(value) {
    //       that.lineChartData.exchang_numData.push(value.exchang_num)
    //       that.lineChartData.sale_after_numData.push(value.sale_after_num)
    //       that.lineChartData.trading_amountData.push(value.trading_amount)
    //       that.lineChartData.user_numData.push(value.user_num)
    //       that.lineChartData.xAxis_data.push(value.md)
    //     })
    //     console.log('get_merchant_data_statistics_msg-res', res)
    //   }).catch(err => {
    //     console.log('err', err)
    //   })
    // },
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .dashboard-editor-container {
    padding: 32px;
    /*background-color: rgb(240, 242, 245);*/
    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 32px;
    }
  }
</style>
